<template>
  <div id="content">
       <div class="detail-content">
        <h1>{{detailContent.title}}</h1>
        <p class="unit">{{detailContent.region}}{{detailContent.county}}{{detailContent.negi}}</p>
        <div class="h2-desc">
          <span>咨询电话：{{detailContent.telephone}}</span>
          <span>{{detailContent.add_time}}</span>
        </div>
        <p class="text-content" v-html="detailContent.content" ></p>
      </div>
  </div>
</template>

<script>
import { Toast, Dialog } from "mand-mobile";
import https from "@/https";
import config from "@/config";
export default {
  components: {
    [Dialog.name]: Dialog,
  },
  name: "content",
  data() {
    return {
      sid: null,
      detailContent: {}, //详情内容
    };
  },
  methods: {
    // 显示消息内容
    getDetail() {
       Toast.loading('加载中...')
      let sid = this.sid;
      let qid = this.$store.state.residentialType.qid;
      let params = {
        sid,
        qid
      };
      https
        .fetchPost(config.guideDetails, params)
        .then(res => {
           Toast.hide()
          if (res.data.code == 1) {
            let content = res.data.data.list;
            content.add_time = this.dataFormat(content.add_time * 1000, 1);
            this.detailContent = content;
          } else {
            Toast.failed(res.data.msg);
          }
        })
        .catch(err => {
           Toast.hide()                                         
          console.log(err);
        });
    },
    // 时间戳转换
    dataFormat(num, type) {
      var dd = new Date(num);
      var y = dd.getFullYear();
      var m = dd.getMonth() + 1;
      var d = dd.getDate();
      var h = dd.getHours();
      var i = dd.getMinutes();
      var s = dd.getSeconds();
      m = m < 10 ? "0" + m : m;
      d = d < 10 ? "0" + d : d;
      h = h < 10 ? "0" + h : h;
      i = i < 10 ? "0" + i : i;
      s = s < 10 ? "0" + s : s;
      if (type == 1) {
        return y + "-" + m + "-" + d + " " + h + ":" + i + ":" + s;
      } else {
        return y + "-" + m + "-" + d + " " + h + ":" + i;
      }
    },
  },
  created() {
    this.sid = this.$route.query.sid;
    this.qid = this.$store.state.residentialType.qid;
    this.getDetail();
  }
};
</script>

<style  lang="scss" scoped>
$themeColor: #444444;
$themeGold: #d7b987;
#content {
  .empty-list {
    padding-top: 100px;
    font-size: 30px;
    color: #666;
    text-align: center;
  }
    .detail-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    h1 {
      font-size: 40px;
      font-weight: 600;
      padding-top: 40px;
      margin-bottom: 40px;
    }
    .unit {
      font-size: 28px;
      color: #666;
      margin-bottom: 30px;
    }
    .h2-desc {
      display: flex;
      align-items: center;
      width: 600px;
      justify-content: space-between;
      font-size: 26px;
      color: #999;
    }
    .text-content {
      padding: 0 30px;
      margin-top: 30px;
      color: #444;
      font-size: 30px;
      line-height: 44px;
      margin-bottom: 40px;
    }
    .img-item {
      // border: 1px solid #f2f2f2;
      width: 600px;
      border-radius: 10px;
      overflow: hidden;
      margin-bottom: 30px;
      img {
        display: block;
        width: 600px;
      }
    }
  }
}
</style>
